<!--专栏-->
<template>
   <div>
       <el-row>
           <el-col :lg="{ span: 21,offset:2}" :md="{span: 22}" class="c-container clearfix">
               <div class="content-left">
                   <div class="post-header"><h1 class="post-title">标签：{{$route.query.name}}</h1></div>
                   <el-row class="container">
                       <el-col class="result c-container clearfix mostPopular" :lg="{ span: 24}" :md="{span: 24}" data-scroll-reveal v-for="(item,index) in result" :key="index">
                           <Row class="setHeight">
                               <Col class="article-time" :xs="4" :sm="4" :md="4" :lg="4">
                               <span>
                          <span>{{item.year}}</span>
                          <span>{{item.month}}</span>
                          <span>{{item.day}}</span>
                     </span>

                               </Col>
                               <Col  class="content-article" :xs="17" :sm="17" :md="17" :lg="17">
                               <span class="title"  @click="renferArticle(item)">{{item.title}}</span>
                               <div>
                                   <span class="letterSpacing">{{item.content}}</span>
                               </div>
                               <div class="search">
                                   <Button class="see-content" @click="renferArticle(item)">查看详情>></Button>
                                   <div class="see-view">
                                       <span class="viewnum f_zt"><Icon type="eye" class="viewnum"></Icon>浏览（{{item.see==null?0:item.see}}）</span>
                                       <span class="likel f_zt"><Icon type="happy-outline" class="likeli"></Icon>喜欢（ {{item.likes==null?0:item.likes}} ）</span>
                                   </div>
                               </div>
                               </Col>
                           </Row>
                       </el-col>
                   </el-row>
               </div>
               <div class="content-right">
                   <RIGHT></RIGHT>
               </div>
           </el-col>
       </el-row>
   </div>
</template>
<style scoped src="../../../../static/css/frontend/link/index.css"></style>
<script>
    import Row from "iview/src/components/grid/row";
    import RIGHT from "../right.vue";
    export default {
        components: {
            Row,
            RIGHT
        },
        props:{

        },
        data () {
            return {
                row:{
                    page:1,
                    per_page:20
                },
                result:{}
            }
        },
        mounted () {
            this.initArticles();
        },
        watch:{
            '$route' (to, from) {
               console.log(this.$route.query.name);
               this.initArticles();
            }
        },
        methods: {
            renferArticle(item){
                this.$router.push({path:'/article?id='+item.id});
            },
            initArticles(){
                var that = this;
                this.fetch({
                    url: '/getLinkContent',
                    method: 'GET',
                    params: {
                        page: that.row.page,
                        per_page: that.row.per_page,
                        id:that.$route.query.id
                    }
                }).then(function (response) {
                    that.result = response.data.rows;
                    if (that.result.length > 0) {
                        for (var i in  that.result) {
                            var data = new Date(that.result[i]['create_time'])
                            that.result[i]['create_time'] = data.toLocaleString('chinese', {hour12: false});
                            that.result[i]['year'] = that.result[i]['create_time'].split('/')[0];
                            that.result[i]['month'] = that.result[i]['create_time'].split('/')[1];
                            that.result[i]['day'] = that.result[i]['create_time'].split('/')[2].split(' ')[0];
                            that.result[i]['time'] = that.result[i]['create_time'].split('/')[2].split(' ')[1];
                        }
                    }
                });
            }

        }
    }
</script>
